﻿@model CanDichVu.Db.ChuyenMuc

@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequest"
    };
}

<script type="text/javascript">

    function completedAjaxRequest(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            if (returnObj.Message != null) {
                confirmOptionNormal(returnObj.Message);
            }
            else if (returnObj.RedirectUrl != null) {
                window.location.href = "/Admin/Ad_Cate/Index";
            }
        } else {
            confirmOptionNormal(returnObj.Message);
        }

        return false;
    }

    $(document).ready(function () {

        $("#tabstrip").kendoTabStrip({
            animation: {
                open: {
                    effects: "fadeIn"
                }
            }
        });

        //onlistCategory();
        var thumblogo = $("img#imageslogo");
        var buttonlogo = $("#event-logo-upload")[0];
        var uploader = new qq.FileUploader({
            element: buttonlogo,
            allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
            sizeLimit: 2147483647, // max size
            action: '/Admin/Admin/UploadImageStr',
            multiple: false,
            onSubmit: function (file, extension) {
                //$('div.preview').addClass('loading');
            },
            onComplete: function (id, fileName, responseJSON) {
                $("#idlogopage").val(responseJSON.filePath);
                thumblogo.attr('src', responseJSON.filePath);
                thumblogo.css('display', 'block');
            }
        });

        var trees = $('#selectCate').combotree({
            url: '/Admin/Ad_Cate/GetCateHoaDorpList',
            onSelect: function (rec) {
                $("#ParentIdCode").val(rec.id);
            }
        });

        $('#selectCate').combotree('setValue', $("#ParentIdCode").val());

    });

    //function onlistCategory() {
    //    var valueID = $("#ParentIdCode").val();
    //    var selectOn = false;
    //    $.getJSON("/Admin/Ad_Cate/AllCategories", { selectedId: 0 },
    //        function (carData) {
    //            var select = $("#selectCate");
    //            select.empty();
    //            $.each(carData, function (index, itemData) {
    //                if (itemData.Value == valueID)
    //                    selectOn = true;
    //                else
    //                    selectOn = false;
    //                select.append($('<option/>', {
    //                    value: itemData.Value,
    //                    text: itemData.Text,
    //                    selected: selectOn
    //                }));
    //            });
    //        });

    //}

    //function onchangeselectCate() {
    //    var value = $("#selectCate").val();
    //    $("#ParentIdCode").val(value);
    //}
</script>

@using (Ajax.BeginForm("AddOrUpdateCate", "Ad_Cate", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div id="content_load_mast_form">
        <div id="tabstrip">
            <ul>
                <li class="k-state-active">Chi Tiet
                </li>
                <li>Seo
                </li>
            </ul>
            <div>
                <div class="chi_tiet">
                    <table class="css_table_form">
                        <tr>
                            <td colspan="2">
                                @Html.HiddenFor(model => model.Id, new { id = "Id" })
                                @Html.HiddenFor(model => model.NgayTao)
                                @Html.HiddenFor(model => model.ParentId, new { id = "ParentIdCode" })
                                @Html.HiddenFor(model => model.Icon, new { id = "idlogopage" })
                                <div class="warning-area">
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.ParentId, "Chuyên mục")
                            </td>
                            <td class="adminData">
                                <select id="selectCate" class="easyui-combotree" style="width:365px; height:27px;">
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.TenChuyenMuc, "Tên chuyên mục")
                            </td>
                            <td class="adminData">
                                @Html.TextBoxFor(model => Model.TenChuyenMuc, new { @class = "txt_inp" })
                                @Html.ValidationMessageFor(model => model.TenChuyenMuc)
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.stt, "Thứ tự hiển thị")
                            </td>
                            <td class="adminData">
                                @Html.TextBoxFor(model => Model.stt, new { @class = "txt_inp" })
                                @Html.ValidationMessageFor(model => model.stt)
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.Icon, "Ảnh đại diện")
                            </td>
                            <td class="adminData">
                                <div id="event-logo-upload" style="">
                                </div>
                                <img src="@Model.Icon" id="imageslogo" width="100px" height="70px" />
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.Hot, "Chuyên mục chính")
                            </td>
                            <td class="adminData">
                                @Html.EditorFor(x => x.Hot)
                                @Html.ValidationMessageFor(model => model.Hot)
                            </td>
                        </tr>
                         <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.set_footer, "Hiển thị Footer")
                            </td>
                            <td class="adminData">
                                @Html.EditorFor(x => x.set_footer)
                                @Html.ValidationMessageFor(model => model.set_footer)
                            </td>
                        </tr>
                    </table>
                </div>
                <span class="rainy">&nbsp;</span>
            </div>
            <div>
                <div class="seo">
                    <table class="css_table_form">
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.Meta_Title, "Meta Title")
                            </td>
                            <td class="adminData">
                                @Html.TextAreaFor(model => Model.Meta_Title, new { rows = "3", cols = "50" })
                                @Html.ValidationMessageFor(model => model.Meta_Title)
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.Meta_KeyWork, "Meta Keywords")
                            </td>
                            <td class="adminData">
                                @Html.TextAreaFor(model => Model.Meta_KeyWork, new { rows = "6", cols = "50" })
                                @Html.ValidationMessageFor(model => model.Meta_KeyWork)
                            </td>
                        </tr>
                        <tr>
                            <td class="adminTitle">
                                @Html.LabelFor(model => model.Meta_Des, "Meta Description")
                            </td>
                            <td class="adminData">
                                @Html.TextAreaFor(model => Model.Meta_Des, new { rows = "10", cols = "50" })
                                @Html.ValidationMessageFor(model => model.Meta_Des)
                            </td>
                        </tr>
                    </table>
                </div>
                <span class="rainy">&nbsp;</span>
            </div>
        </div>
         <div class="footer_submit">
            <div class="warning-area"></div>
            <button type="submit" onclick="return makeloadingForm();" class="editButton k-button k-button-icontext" data-role="button" role="button" aria-disabled="false" tabindex="0">
                <span class="k-sprite k-icon k-edit"></span>Lưu</button>
            <button type="button" onclick="return close_window('window_update_object');" class="closeButton k-button k-button-icontext" data-role="button" role="button" aria-disabled="false" tabindex="0">
                <span class="k-icon k-i-close"></span>Hủy bỏ</button>
        </div>
    </div>
 
}
